package cn.lycode.system.domain.dto.sysdict;

import cn.lycode.common.enums.TrueFalseEnum;
import cn.lycode.common.utils.SecurityUtils;
import cn.lycode.system.domain.entity.SysDictType;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 字典类型修改
 */
@Data
public class SysDictTypeUpDTO {

    @NotNull(message = "id不能为")
    private Long id;

    @NotBlank(message = "字典名称不能为空")
    private String typeName; //

    @NotBlank(message = "字典码不能为空")
    private String typeCode;

    @NotBlank(message = "字典分类不能为空")
    private String dictClassify; //字典分类

    private TrueFalseEnum isDisable; //是否禁用

    private String remark;//备注

    public SysDictType buildUpEntity(){
        SysDictType sysDictType = new SysDictType();
        sysDictType.setId(id);
        sysDictType.setTypeName(typeName);
        sysDictType.setTypeCode(typeCode);
        sysDictType.setDictClassify(dictClassify);
        sysDictType.setRemark(remark);
        sysDictType.setIsDisable(isDisable);
        sysDictType.setUpdateBy(SecurityUtils.getLoginUsername());
        sysDictType.setUpdateTime(new Date());
        return sysDictType;
    }
}
